//
// Created by linyongzhi on 2023/12/21.
//

#include "CPHYuvUtil.h"

int CPHYuvUtil::I420Rotate(uint8_t *src, int src_width, int src_height) {
    uint8_t *scaled_y = src;
    uint8_t *scaled_u = scaled_y + src_width * src_height;
    uint8_t *scaled_v = scaled_u + src_width * src_height / 4;

    uint8_t *rotated_y = m_dst;
    uint8_t *rotated_u = rotated_y + m_width * m_height;
    uint8_t *rotated_v = rotated_u + m_width * m_height / 4;

    int ret = libyuv::I420Rotate(scaled_y, src_width, scaled_u, src_width >> 1, scaled_v, src_width >> 1, rotated_y,
                                 m_height, rotated_u, m_height >> 1, rotated_v, m_height >> 1, src_width,
                         src_height, libyuv::kRotate270);
    return ret;
}

uint8_t *CPHYuvUtil::GetDest() {
    return m_dst;
}


